import { DomUtils } from '../utils/DomUtilsMin';


/**
 * 百度贴吧网页美化
 * 
 * 测试页面：
 * - https://tieba.baidu.com/p/6697214860#/
 */
export class BaiduTieba {

    static hostname = 'tieba.baidu.com';   

    main() {
        DomUtils.observe('uni-page-body > uni-view', ['childList'], { childList: true }, 
            ({ observer, target, index }) => {
            // 打开APP遮罩弹窗
            const openAppModel = target.querySelector('.tb-backflow-defensive');
            if (openAppModel) {
                openAppModel.style.display = 'none';
                index++;
            }
            // 底部导航条
            const bottomBar = target.querySelector('.operation-area-login');
            if (bottomBar) {
                bottomBar.style.display = 'none';
                index++;
            }
            // 隐藏 加载更多评论 按钮
            const loadMore = target.querySelector('.load-wrapper');
            if (loadMore) {
                loadMore.style.display = 'none';
                index++;
            }
            // 展开评论
            const comments = target.querySelector('.swiper-content');
            if (comments) {
                comments.classList.remove('swiper-content-first');
                index++;
            }
            // 去除页面下边距
            const content = target.querySelector('.content');
            if (content) {
                content.style.paddingBottom = 0;
                index++;
            }
            index === 5 && observer.disconnect();
        });
    }
}